<template>
  <div id="docOrderDetails">
    <header>
      <i @click="goBack()"></i>
      <div>订单详情</div>
    </header>
    <div class="gbd-shopping-cart-gotobuy" @click="enter()" v-if="status=='pay'">
      查询医生使用时间信息
    </div>
    <div class="box">
      <ul class="order">
        <li>
          <span>预约时长:</span>
          <div>{{docinfo.select_timeArr | getLen}}个小时</div>
        </li>
        <li>
          <span>就诊日期:</span>
          <div>{{docinfo.startdate}}</div>
        </li>
        <li>
          <span>诊室选择:</span>
          <div>{{docinfo.chairname}}</div>
        </li>
        <li>
          <span>就诊时段:</span>
          <div>{{docinfo.select_timeArr | toStr}}</div>
        </li>
        <!-- <li>
          <span>合作方式:</span>
          <div style="color:red " v-html="way"></div>
        </li> -->
        <li>
          <span>手术类型:</span>
          <div>{{docinfo.docType}}</div>
        </li>
        <li>
          <span>医生姓名:</span>
          <div>{{name}}</div>
        </li>
        <li>
          <span>手机号:</span>
          <div>{{phone}}</div>
        </li>
      </ul>
      <ul class="orderDetails">
        <li>
          <span>
            商品明细
          </span>
        </li>
        <li v-for='(item,index) in gids' :key='index' v-if="gids.length>0">
          <img :src="item.img_url" width='45' height="45" alt="">
          <h3>{{item.name}}</h3>
          <div>
            <i>x{{item.num}}</i>
            <span>￥{{item.price}}</span>
          </div>
        </li>
      </ul>
      <ul class="order">
        <li>
          <span>订单时间:</span>
          <div>{{orderObj.time}}</div>
        </li>
        <li>
          <span>订单编号:</span>
          <div class="order_num">{{orderObj.order_num}}</div>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
  import {
    MessageBox
  } from 'mint-ui';
  export default {
    data() {
      return {
        status:'',//状态
        name: '', //姓名
        phone: '', //电话
        way: '', //合作方式
        time: '',
        statu: '',
        id: '', //订单id
        orderObj: {},
        gids: [],
        docinfo: {}, //医生下单信息
        infoObj: {},
        type: '',
        timeOutEvent: 0,
        user: '', //判断入口 医生or诊室
        start: '',
        end: '',
        obj: {
          starttime: '',
          endtime: '',
        },
      }
    },
    filters: {
      // 把数字转换成字符串
      toStr(arr) {
        if (arr) {
          const str = arr.join();
          return str;
        }
      },
      // 获取数组长度
      getLen(arr) {
        if (arr) {
          const len = arr.length;
          return len;
        }
      },
    },
    methods: {
      //返回上一级
      goBack() {
        this.$router.back();
      },
      enter() {
        this.$router.push({
          name: 'useTime',
          query: {
            orderId: this.orderObj.order_num,
            chairname: this.docinfo.chairname
          }
        })

      },
      //判断入口 医生还是诊室
      judgmentUser() {
        this.user = this.$route.query.user;
        this.id = this.$route.query.id;
        this.type = this.$route.query.type;
      },
      // 根据id获取订单详情
      getObj() {
        this.$api.get(this.$api.baseURLSchool, "select_cid/view_doctor_order_clinic/" + this.id, {}, r => {
          if (r.data.ret == 1) {
            this.status=r.data.info.status;
            this.orderObj = r.data.info;
            this.gids = JSON.parse(this.orderObj.gids);
            this.docinfo = JSON.parse(this.orderObj.docinfo);
            this.infoObj = JSON.parse(this.orderObj.infoObj);
            this.way = this.docinfo.way1;
          }
        }, err => {
          console.log(err);
        })
      },
    },
    created() {
      this.name = localStorage.getItem('doctorName')
      this.phone = localStorage.getItem('loginMobile')
      this.judgmentUser();
      this.getObj();
    }
  }

</script>
<style lang="scss" scoped>
  .order_num {
    width: 2.8rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

</style>
